﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;

namespace YXShop.Web.admin.templates
{
    public partial class amendlable : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string dir = Request.QueryString["dir"];
                string filename = Request.QueryString["filename"];
                YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
                string str_FilePath = ChangeHope.Common.ServerInfo.GetRootPath().Trim('\\');
                string TemplatePath = Server.MapPath(dir) + "\\" + filename;
                YXShop.TemplateAction.Template indexTemp = new YXShop.TemplateAction.Template(TemplatePath);
                indexTemp.BackPath(filename, dir.Replace("~\\",""));
                indexTemp.GetHTML();
                indexTemp.GetEidtLable(true);
                indexTemp.ReplaceLabels();
                string getContent = indexTemp.FinallyContent;
                if (Regex.Match(getContent, @"\</head\>[\s\S]*\<body", RegexOptions.IgnoreCase | RegexOptions.Compiled).Success)
                {
                    getContent = Regex.Replace(getContent, "<body", "<body", RegexOptions.IgnoreCase | RegexOptions.Compiled);
                }
                
                Response.Write(getContent);
                Response.Write("<script src=\"" + sp.DummyPaht + "admin/scripts/label.js\" type=\"text/javascript\"  charset=\"UTF-8\"></script>");
            }
        }
    }
}
